import org.mybatis.generator.api.MyBatisGenerator;
import org.mybatis.generator.config.*;
import org.mybatis.generator.config.xml.ConfigurationParser;
import org.mybatis.generator.internal.DefaultShellCallback;

import java.io.File;
import java.net.URL;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;

public class MybatisGeneratorUseXml {

  private String getXmlPath() {
    URL resource = this.getClass().getResource("/");
    return resource.getPath();
  }

  public static void main(String[] args) throws Exception {

    MybatisGeneratorUseXml generatorUseXml = new MybatisGeneratorUseXml();
    generatorUseXml.getXmlPath();

    List<String> warnings = new ArrayList<String>();
    boolean overwrite = true;
    String projectPath = System.getProperty("user.dir");
    File configFile = new File(projectPath + "\\mybatis\\src\\main\\resources\\generatorConfig.xml");
    ConfigurationParser cp = new ConfigurationParser(warnings);
    Configuration config = cp.parseConfiguration(configFile);
    DefaultShellCallback callback = new DefaultShellCallback(overwrite);
    MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
    myBatisGenerator.generate(null);
  }


}
